package com.feri.fss.controller;

import com.feri.fss.common.vo.PageBean;
import com.feri.fss.common.vo.R;
import com.feri.fss.entity.Admin;
import com.feri.fss.service.intf.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @author Feri
 * @date 2021/12/16 10:22
 * @description:TODO
 */
@Controller //IOC创建对象
@RequestMapping("/api/admin/") //配置url地址
public class AdminController {
    @Autowired
    private AdminService service;

    //登录
    @RequestMapping("login.do")
    @ResponseBody
    public R login(String name, String password, HttpSession session){
        return service.login(name, password, session);
    }

    //新增
    @RequestMapping("save.do")
    @ResponseBody
    public R save(Admin admin){
        return service.save(admin);
    }

    //查询-分页
    @RequestMapping("page.do")
    @ResponseBody
    public PageBean page(int page, int limit){
        return service.queryPage(page, limit);
    }

    //删除
    @RequestMapping("delete.do")
    @ResponseBody
    public R delete(int id){
        return service.delById(id);
    }

    //修改
    @RequestMapping("update.do")
    @ResponseBody
    public R update(Admin admin){
        return service.update(admin);
    }
}
